package com.oracle.mapper;

import com.oracle.pojo.Permission;
import com.oracle.pojo.Roles;
import com.oracle.pojo.RolesExample;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface RolesMapper {
    int countByExample(RolesExample example);

    int deleteByExample(RolesExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Roles record);

    int insertSelective(Roles record);

    List<Roles> selectByExample(RolesExample example);

    Roles selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Roles record, @Param("example") RolesExample example);

    int updateByExample(@Param("record") Roles record, @Param("example") RolesExample example);

    int updateByPrimaryKeySelective(Roles record);

    int updateByPrimaryKey(Roles record);

    @Select("select p.urls from permission p left join role_permission rp on(p.id=rp.permission) " +
            "left join admin_role ar on(rp.role=ar.role) where ar.admin=#{id}")
    List<String> selectPermissionsByAdminid(Integer id);

    @Select("select * from permission ")
    List<Permission> selectPermissionsAll();

    @Select("select permission from role_permission where role=#{id}")
    List<Integer> selectPermissionsByRoleId(Integer id);

    @Insert("insert into role_permission(role,permission) values(#{role},#{permission})")
    int insertRoleAndPermissions(@Param("role") Integer id, @Param("permission") Integer perid);

    @Delete("delete from role_permission where role=#{role}")
    int deletePermissionsByRoleId(@Param("role")Integer id);
}